//package common;
//
//import entity.AccountLocal;
//import java.util.ArrayList;
//import javax.servlet.ServletContext;
//import javax.servlet.http.HttpSessionBindingEvent;
//import javax.servlet.http.HttpSessionBindingListener;
//
///**
// *
// * @author Giang Nguyen
// */
//public class UserBindListener implements HttpSessionBindingListener {
//
//    private ServletContext servletContext;
//    private AccountLocal account;
//
//    public UserBindListener(ServletContext servletContext, AccountLocal account) {
//        this.servletContext = servletContext;
//        this.account = account;
//    }
//
//    public void valueBound(HttpSessionBindingEvent event) {
//        Object obj = servletContext.getAttribute(Constant.USERLIST);
//        if (obj == null) {
//            ArrayList userList = new ArrayList();
//            userList.add(account);
//            servletContext.setAttribute(Constant.USERLIST, userList);
//        } else {
//            ArrayList userList = (ArrayList) obj;
//            userList.add(account);
//        }
//    }
//
//    public void valueUnbound(HttpSessionBindingEvent event) {
//        Object obj = servletContext.getAttribute(Constant.USERLIST);
//        if (obj == null) {
//            ArrayList userList = new ArrayList();
//            servletContext.setAttribute(Constant.USERLIST, userList);
//        } else {
//            ArrayList userList = (ArrayList) obj;
//            userList.remove(account);
//        }
//    }
//
//    public AccountLocal getUser() {
//        return account;
//    }
//}
